package com.maker.controller;

import com.maker.entity.OrderInfo;
import com.maker.entity.TableDataInfo;
import com.maker.service.OrderInfoRepository;
import io.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/order")
@Api(tags = "订单操作")
@Slf4j
public class OrderInfoController {

    @Resource
    private OrderInfoRepository orderInfoRepository;


    @RequestMapping("/list")
    @ResponseBody
    public TableDataInfo list()
    {
        List<OrderInfo> all = orderInfoRepository.findAll();
        TableDataInfo dataInfo = new TableDataInfo();
        if(all == null || all.isEmpty()){
            return dataInfo;
        }
        int size = all.size();
        dataInfo.setTotal(size);
        dataInfo.setRows(all);
        return dataInfo;
    }
}
